package com.mzy.linear_struct.面试150题;

/**
 * @Author: mizy3
 * @Date: 2024/08/15/下午2:36
 * @Description:
 */
public class Pro392判断子序列 {

    public boolean isSubsequence(String s, String t) {

        char[] ss = s.toCharArray();
        char[] tt = t.toCharArray();

        int i = 0, j = 0;
        int count = 0;
        //  i
        // b
        // a b c
        //  j
        while (i < ss.length && j < tt.length){
            if (ss[i] == tt[j]) {
                count++;
                i++;
            }
            j++;
        }

        return count == s.length();
    }
}
